#Criando seleção com filtro
## Warning in readRDS(dest): lzma decoding result 10
## Warning: package 'funModeling' is not available for this version of R
##
## A version of this package for your version of R might be available elsewhere,
## see the ideas at
## https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
## Warning: 'BiocManager' not available. Could not check Bioconductor.
##
## Please use `install.packages('BiocManager')` and then retry.
## Warning in p_install(package, character.only = TRUE, ...):
## Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
## logical.return = TRUE, : there is no package called 'funModeling'
## Warning in pacman::p_load(crosstalk, dplyr, DT, plotly, ade4, car, mboost, : Failed to install/load:
## funModeling
## observado previsao
## 2 1.8 1.612801
## 3 1.6 1.628995
## 6 2.0 1.665639
## 7 1.5 1.624189
## 8 1.5 1.699835
## 12 1.4 1.628120
## 13 1.7 1.787987
## 16 1.6 1.645514
## 18 1.8 1.668377
## 25 1.7 1.700882
## 28 2.0 1.672643
## 32 1.6 1.665695
## 33 1.5 1.616371
## 40 1.6 1.639984
## 41 1.6 1.643969
## 47 1.8 1.657652
## 49 1.8 1.609474
## 51 1.8 1.632020
## 54 1.5 1.610021
## 57 1.7 1.627929
## 65 1.6 1.653578
## 68 2.5 5.432946
## 69 1.8 1.608522
## 72 1.6 1.667171
## 73 1.6 1.607926
## 74 2.1 2.060161
## 79 3.2 3.533053
## 80 1.7 1.698478
## 83 1.5 1.644211
## 84 1.7 1.613960
## 87 2.0 2.072357
## 90 1.8 1.633803
## 91 1.7 1.660387
## 94 1.5 1.625388
## 100 1.4 1.701618
## 104 1.4 1.683280
## 118 1.4 1.694352
## 121 1.6 1.806402
## 123 1.7 1.665142
## 128 1.6 1.660173
## 131 1.7 1.603065
## 132 3.3 -1.192398
## 150 1.6 1.653258
## 151 1.6 1.642593
## 159 1.3 1.637870
## 160 2.4 1.721689
## 167 1.5 1.628467
## 169 1.7 1.615920
## 173 1.6 1.617061
## 174 1.7 1.652056
## 176 1.8 1.651589
## 180 1.5 1.639594
## 182 1.5 1.699076
## 184 1.3 1.625135
## [1] "Erro Quadrático Médio (MSE): 0.567375196003104"
## Warning in nominalTrainWorkflow(x = x, y = y, wts = weights, info = trainInfo,
## : There were missing values in resampled performance measures.
## Aggregating results
## Selecting tuning parameters
## Fitting alpha = 0.479, lambda = 0.0436 on full training set
## Length Class Mode
## a0 100 -none- numeric
## beta 700 dgCMatrix S4
## df 100 -none- numeric
## dim 2 -none- numeric
## lambda 100 -none- numeric
## dev.ratio 100 -none- numeric
## nulldev 1 -none- numeric
## npasses 1 -none- numeric
## jerr 1 -none- numeric
## offset 1 -none- logical
## call 5 -none- call
## nobs 1 -none- numeric
## lambdaOpt 1 -none- numeric
## xNames 7 -none- character
## problemType 1 -none- character
## tuneValue 2 data.frame list
## obsLevels 1 -none- logical
## param 0 -none- list
## 8 x 1 sparse Matrix of class "dgCMatrix"
## s1
## (Intercept) 1.648431e+00
## pop .
## pib 1.843440e-11
## vab .
## icms 1.217506e-07
## ipi 3.012624e-05
## ipva .
## pop_ocu_per .
## Warning in nominalTrainWorkflow(x = x, y = y, wts = weights, info = trainInfo,
## : There were missing values in resampled performance measures.
## Aggregating results
## Selecting tuning parameters
## Fitting cp = 0.0338 on full training set
## Call:
## (function (formula, data, weights, subset, na.action = na.rpart,
## method, model = FALSE, x = FALSE, y = TRUE, parms, control,
## cost, ...)
## {
## Call <- match.call()
## if (is.data.frame(model)) {
## m <- model
## model <- FALSE
## }
## else {
## indx <- match(c("formula", "data", "weights", "subset"),
## names(Call), nomatch = 0)
## if (indx[1] == 0)
## stop("a 'formula' argument is required")
## temp <- Call[c(1, indx)]
## temp$na.action <- na.action
## temp[[1]] <- quote(stats::model.frame)
## m <- eval.parent(temp)
## }
## Terms <- attr(m, "terms")
## if (any(attr(Terms, "order") > 1))
## stop("Trees cannot handle interaction terms")
## Y <- model.response(m)
## wt <- model.weights(m)
## if (any(wt < 0))
## stop("negative weights not allowed")
## if (!length(wt))
## wt <- rep(1, nrow(m))
## offset <- model.offset(m)
## X <- rpart.matrix(m)
## nobs <- nrow(X)
## nvar <- ncol(X)
## if (missing(method)) {
## method <- if (is.factor(Y) || is.character(Y))
## "class"
## else if (inherits(Y, "Surv"))
## "exp"
## else if (is.matrix(Y))
## "poisson"
## else "anova"
## }
## if (is.list(method)) {
## mlist <- method
## method <- "user"
## init <- if (missing(parms))
## mlist$init(Y, offset, wt = wt)
## else mlist$init(Y, offset, parms, wt)
## keep <- rpartcallback(mlist, nobs, init)
## method.int <- 4
## parms <- init$parms
## }
## else {
## method.int <- pmatch(method, c("anova", "poisson", "class",
## "exp"))
## if (is.na(method.int))
## stop("Invalid method")
## method <- c("anova", "poisson", "class", "exp")[method.int]
## if (method.int == 4)
## method.int <- 2
## init <- if (missing(parms))
## get(paste("rpart", method, sep = "."), envir = environment())(Y,
## offset, , wt)
## else get(paste("rpart", method, sep = "."), envir = environment())(Y,
## offset, parms, wt)
## ns <- asNamespace("rpart")
## if (!is.null(init$print))
## environment(init$print) <- ns
## if (!is.null(init$summary))
## environment(init$summary) <- ns
## if (!is.null(init$text))
## environment(init$text) <- ns
## }
## Y <- init$y
## xlevels <- .getXlevels(Terms, m)
## cats <- rep(0, ncol(X))
## if (!is.null(xlevels)) {
## indx <- match(names(xlevels), colnames(X), nomatch = 0)
## cats[indx] <- (unlist(lapply(xlevels, length)))[indx >
## 0]
## }
## extraArgs <- list(...)
## if (length(extraArgs)) {
## controlargs <- names(formals(rpart.control))
## indx <- match(names(extraArgs), controlargs, nomatch = 0)
## if (any(indx == 0))
## stop(gettextf("Argument %s not matched", names(extraArgs)[indx ==
## 0]), domain = NA)
## }
## controls <- rpart.control(...)
## if (!missing(control))
## controls[names(control)] <- control
## xval <- controls$xval
## if (is.null(xval) || (length(xval) == 1 && xval == 0) ||
## method == "user") {
## xgroups <- 0
## xval <- 0
## }
## else if (length(xval) == 1) {
## xgroups <- sample(rep(1:xval, length.out = nobs), nobs,
## replace = FALSE)
## }
## else if (length(xval) == nobs) {
## xgroups <- xval
## xval <- length(unique(xgroups))
## }
## else {
## if (!is.null(attr(m, "na.action"))) {
## temp <- as.integer(attr(m, "na.action"))
## xval <- xval[-temp]
## if (length(xval) == nobs) {
## xgroups <- xval
## xval <- length(unique(xgroups))
## }
## else stop("Wrong length for 'xval'")
## }
## else stop("Wrong length for 'xval'")
## }
## if (missing(cost))
## cost <- rep(1, nvar)
## else {
## if (length(cost) != nvar)
## stop("Cost vector is the wrong length")
## if (any(cost <= 0))
## stop("Cost vector must be positive")
## }
## tfun <- function(x) if (is.matrix(x))
## rep(is.ordered(x), ncol(x))
## else is.ordered(x)
## labs <- sub("^`(.*)`$", "\\1", attr(Terms, "term.labels"))
## isord <- unlist(lapply(m[labs], tfun))
## storage.mode(X) <- "double"
## storage.mode(wt) <- "double"
## temp <- as.double(unlist(init$parms))
## if (!length(temp))
## temp <- 0
## rpfit <- .Call(C_rpart, ncat = as.integer(cats * !isord),
## method = as.integer(method.int), as.double(unlist(controls)),
## temp, as.integer(xval), as.integer(xgroups), as.double(t(init$y)),
## X, wt, as.integer(init$numy), as.double(cost))
## nsplit <- nrow(rpfit$isplit)
## ncat <- if (!is.null(rpfit$csplit))
## nrow(rpfit$csplit)
## else 0
## if (nsplit == 0)
## xval <- 0
## numcp <- ncol(rpfit$cptable)
## temp <- if (nrow(rpfit$cptable) == 3)
## c("CP", "nsplit", "rel error")
## else c("CP", "nsplit", "rel error", "xerror", "xstd")
## dimnames(rpfit$cptable) <- list(temp, 1:numcp)
## tname <- c("<leaf>", colnames(X))
## splits <- matrix(c(rpfit$isplit[, 2:3], rpfit$dsplit), ncol = 5,
## dimnames = list(tname[rpfit$isplit[, 1] + 1], c("count",
## "ncat", "improve", "index", "adj")))
## index <- rpfit$inode[, 2]
## nadd <- sum(isord[rpfit$isplit[, 1]])
## if (nadd > 0) {
## newc <- matrix(0, nadd, max(cats))
## cvar <- rpfit$isplit[, 1]
## indx <- isord[cvar]
## cdir <- splits[indx, 2]
## ccut <- floor(splits[indx, 4])
## splits[indx, 2] <- cats[cvar[indx]]
## splits[indx, 4] <- ncat + 1:nadd
## for (i in 1:nadd) {
## newc[i, 1:(cats[(cvar[indx])[i]])] <- -as.integer(cdir[i])
## newc[i, 1:ccut[i]] <- as.integer(cdir[i])
## }
## catmat <- if (ncat == 0)
## newc
## else {
## cs <- rpfit$csplit
## ncs <- ncol(cs)
## ncc <- ncol(newc)
## if (ncs < ncc)
## cs <- cbind(cs, matrix(0, nrow(cs), ncc - ncs))
## rbind(cs, newc)
## }
## ncat <- ncat + nadd
## }
## else catmat <- rpfit$csplit
## if (nsplit == 0) {
## frame <- data.frame(row.names = 1, var = "<leaf>", n = rpfit$inode[,
## 5], wt = rpfit$dnode[, 3], dev = rpfit$dnode[, 1],
## yval = rpfit$dnode[, 4], complexity = rpfit$dnode[,
## 2], ncompete = 0, nsurrogate = 0)
## }
## else {
## temp <- ifelse(index == 0, 1, index)
## svar <- ifelse(index == 0, 0, rpfit$isplit[temp, 1])
## frame <- data.frame(row.names = rpfit$inode[, 1], var = tname[svar +
## 1], n = rpfit$inode[, 5], wt = rpfit$dnode[, 3],
## dev = rpfit$dnode[, 1], yval = rpfit$dnode[, 4],
## complexity = rpfit$dnode[, 2], ncompete = pmax(0,
## rpfit$inode[, 3] - 1), nsurrogate = rpfit$inode[,
## 4])
## }
## if (method.int == 3) {
## numclass <- init$numresp - 2
## nodeprob <- rpfit$dnode[, numclass + 5]/sum(wt)
## temp <- pmax(1, init$counts)
## temp <- rpfit$dnode[, 4 + (1:numclass)] %*% diag(init$parms$prior/temp)
## yprob <- temp/rowSums(temp)
## yval2 <- matrix(rpfit$dnode[, 4 + (0:numclass)], ncol = numclass +
## 1)
## frame$yval2 <- cbind(yval2, yprob, nodeprob)
## }
## else if (init$numresp > 1)
## frame$yval2 <- rpfit$dnode[, -(1:3), drop = FALSE]
## if (is.null(init$summary))
## stop("Initialization routine is missing the 'summary' function")
## functions <- if (is.null(init$print))
## list(summary = init$summary)
## else list(summary = init$summary, print = init$print)
## if (!is.null(init$text))
## functions <- c(functions, list(text = init$text))
## if (method == "user")
## functions <- c(functions, mlist)
## where <- rpfit$which
## names(where) <- row.names(m)
## ans <- list(frame = frame, where = where, call = Call, terms = Terms,
## cptable = t(rpfit$cptable), method = method, parms = init$parms,
## control = controls, functions = functions, numresp = init$numresp)
## if (nsplit)
## ans$splits = splits
## if (ncat > 0)
## ans$csplit <- catmat + 2
## if (nsplit)
## ans$variable.importance <- importance(ans)
## if (model) {
## ans$model <- m
## if (missing(y))
## y <- FALSE
## }
## if (y)
## ans$y <- Y
## if (x) {
## ans$x <- X
## ans$wt <- wt
## }
## ans$ordered <- isord
## if (!is.null(attr(m, "na.action")))
## ans$na.action <- attr(m, "na.action")
## if (!is.null(xlevels))
## attr(ans, "xlevels") <- xlevels
## if (method == "class")
## attr(ans, "ylevels") <- init$ylevels
## class(ans) <- "rpart"
## ans
## })(formula = .outcome ~ ., data = list(c(100346, 25065, 37082,
## 22984, 22870, 11226, 74822, 14510, 12122, 76687, 12765, 60880,
## 38378, 48767, 39983, 8987, 7488, 13190, 58919, 208944, 28904,
## 11018, 5747, 158899, 18900, 8572, 19609, 13025, 84395, 365278,
## 14368, 11891, 21815, 18268, 12560, 24173, 37375, 69292, 31766,
## 22247, 12170, 22618, 33184, 15546, 140577, 30751, 84699, 19241,
## 12247, 26672, 23645, 4543, 4966, 26308, 26900, 17006, 11644,
## 17228, 16011, 11485, 15431, 21460, 18252, 13224, 16318, 40589,
## 56198, 25472, 21776, 11220, 15470, 11270, 63294, 32573, 393115,
## 23935, 15152, 69969, 63500, 7600, 26456, 22106, 28894, 334376,
## 67735, 36901, 354317, 11305, 15101, 26175, 20646, 47616, 23628,
## 9764, 11068, 61249, 15862, 26890, 15558, 12650, 109897, 14562,
## 42100, 14223, 11865, 16069, 60042, 21398, 21586, 34021, 34056,
## 114079, 18085, 86915, 46361, 6021, 65647, 28704, 12859, 26106,
## 29127, 10206, 52802, 46164, 15243, 8256, 18661, 9553, 20954,
## 139583), c(1725530040, 254433749, 246012396, 171957774, 223576627,
## 118494207, 1007778325, 129193317, 80071216, 1883328580, 87858630,
## 722013305, 276756188, 503785177, 327251686, 144883318, 55555609,
## 103451021, 406916743, 9758236662, 486379337, 93547528, 50248156,
## 1850647501, 153617568, 129829606, 154574536, 78625308, 1447601312,
## 7147526418, 94875081, 88575588, 199848143, 149792966, 119516551,
## 263969197, 497295327, 956663959, 268382301, 191063979, 112514665,
## 170092843, 418863027, 115759710, 2441308810, 456747907, 1124665213,
## 161992547, 89714876, 249443705, 167130866, 36207443, 55403615,
## 215492010, 1563044592, 132513399, 109198668, 124670220, 183360566,
## 100427145, 104187918, 320808438, 247578348, 115729415, 140251656,
## 446585824, 776093813, 238820003, 122157971, 87524952, 151214926,
## 81820138, 657888056, 528191186, 5533876468, 321655345, 173757567,
## 666745141, 800303528, 68717743, 190163512, 166902596, 224562554,
## 4190092519, 688562864, 1329912205, 6686658334, 83988256, 159162571,
## 179830993, 181657839, 448647830, 266502475, 125396696, 67495839,
## 858917924, 127168967, 199171392, 108750766, 90615401, 1511867664,
## 97983803, 660076031, 102556274, 85905281, 96619312, 1085366267,
## 160376964, 231879079, 271435682, 384206259, 1181132228, 213004395,
## 1373040468, 490988356, 43970016, 753840601, 265325241, 162555722,
## 173317009, 280500896, 68548740, 681732740, 654978750, 142051785,
## 78738813, 215607654, 68372803, 160055642, 3718817024), c(656390983,
## 83058312, 60468092, 47936240, 54176074, 19820377, 542244942,
## 25321515, 18405707, 511398132, 19780174, 280700841, 64331238,
## 151358767, 87849926, 20411079, 12737860, 24536154, 98875695,
## 3737740286, 45771274, 17670743, 13932436, 895966678, 55543895,
## 29986202, 44081240, 13947979, 620429564, 3839255608, 17748496,
## 22133022, 62673519, 33220844, 27031067, 102358182, 204199679,
## 329322973, 76398156, 54779483, 33804131, 48997413, 168202548,
## 31643252, 1150729004, 110636358, 536409265, 33057414, 22652537,
## 97655864, 39973382, 7856614, 12177633, 54149398, 347202101, 29500907,
## 22950226, 34331916, 38463661, 16824806, 24566718, 82369842, 65314214,
## 20584297, 24271695, 180915672, 375196597, 82318734, 20986459,
## 18120373, 58076334, 18545287, 192977143, 173844762, 2849259015,
## 60375043, 34222248, 263996287, 419643739, 13036578, 47294417,
## 50318389, 68384013, 1932782631, 265147648, 243063483, 2960723368,
## 21387963, 33332696, 43339918, 50796743, 140027001, 66377057,
## 39555913, 12383244, 447705972, 29929054, 58978805, 25821538,
## 22328772, 661367763, 20889019, 118306474, 29041006, 21105857,
## 16939256, 160053769, 44238346, 99389556, 88972910, 130311800,
## 468049165, 49423963, 691459819, 138488056, 9284260, 356037259,
## 106817596, 32587156, 40800382, 88584368, 16488295, 306009949,
## 272313410, 52006041, 27278430, 46973235, 15190000, 54715746,
## 1489988724), c(205327.94, 26285.21, 21192.56, 20662.94, 31107.66,
## 15184.68, 87801.63, 20137.98, 21177.12, 160308.46, 16413.15,
## 51624.99, 25987.95, 43608.99, 36364.88, 24030.24, 29051.53, 28128.57,
## 38201.54, 1253816.42, 38077.36, 26597.41, 24851.7, 24851.7, 21348.37,
## 27201.12, 23898.83, 16223.84, 116117.13, 536035.02, 17424.6,
## 23139.23, 21609.62, 22588.99, 27608.49, 25380.22, 47726.5, 89629.59,
## 26818.43, 23313.91, 28265.1, 20327.55, 85619.6, 17364.45, 202846.33,
## 54799.93, 94618.46, 19008.16, 23671.65, 0, 18310.85, 20396.59,
## 45589.13, 25099.22, 189121.23, 18557.23, 22810.01, 17325.3, 35161.42,
## 16273.79, 16297.23, 16297.23, 35880.26, 23386.49, 18050.68, 34829.85,
## 62734.83, 25233.95, 20332.44, 20898.14, 16139.09, 21357.44, 55825.63,
## 47666.34, 608979.03, 26326.16, 15455.67, 40390.31, 60102.21,
## 22105.31, 21168.66, 19735.35, 21994.96, 383196.34, 55423, 84990.55,
## 493916.22, 16764.25, 30122.11, 19279.42, 20043.94, 45095.03,
## 63235.37, 23159.69, 34009.98, 69049.75, 17919.04, 19099.07, 17248.53,
## 18787.42, 105552.43, 22524.85, 27766.37, 17976.55, 18039.87,
## 16502.54, 45298.25, 26084.73, 21789.66, 25301.45, 29154.81, 88321.43,
## 21354.07, 112054.41, 90898.45, 27315.34, 52306.11, 25647.65,
## 16562.04, 44020.37, 23554.19, 29365.02, 60708.58, 53025.58, 24209.26,
## 18255.98, 26409.04, 16775.35, 17776.34, 377043.29), c(823.29,
## 107.2, 85.71, 83.59, 125.91, 61.45, 355.28, 81.45, 85.7, 647.34,
## 66.39, 209.56, 105.16, 178.25, 147.15, 99.02, 117.57, 113.83,
## 154.6, 5021.78, 154.02, 107.6, 100.54, 100.54, 87.1, 104.55,
## 96.65, 65.69, 469.66, 2168.11, 70.94, 93.66, 87.45, 91.41, 111.76,
## 103.39, 194.45, 363.75, 108.51, 94.52, 114.42, 82.23, 346.62,
## 70.26, 822.02, 221.8, 383.2, 76.89, 95.75, 0, 74.07, 82.51, 184.61,
## 101.52, 763.21, 75.44, 92.31, 70.11, 142.28, 65.86, 65.93, 65.93,
## 150.06, 94.61, 73.01, 141.69, 253.8, 102.08, 82.28, 84.56, 65.32,
## 86.45, 225.81, 192.85, 2464.72, 106.48, 62.51, 163.37, 243.13,
## 91.41, 85.84, 79.85, 88.98, 1550.27, 224.2, 345.81, 2003.6, 67.83,
## 121.95, 78.01, 81.07, 182.5, 255.95, 95.02, 137.69, 279.29, 72.48,
## 77.27, 69.8, 76.03, 426.96, 91.18, 112.32, 72.93, 73, 66.77,
## 183.22, 107.03, 88.15, 102.37, 117.95, 357.29, 86.4, 453.33,
## 367.87, 110.55, 211.58, 103.73, 67.01, 178.21, 95.29, 118.86,
## 245.58, 214.53, 97.96, 73.85, 108.34, 67.9, 71.89, 1531.72),
## c(36815.55, 6841.95, 3939.39, 4097.53, 3324.87, 2160.16,
## 39263.23, 2137.24, 1456.08, 28180.13, 2095.89, 24346.14,
## 5390.34, 9883.51, 8418.68, 1863.71, 854.15, 2518.67, 8690.43,
## 80203.6, 5311.85, 1975.02, 1818.66, 1818.66, 4605.92, 2355.32,
## 4140.65, 1206.93, 43476.53, 251533.75, 1829.01, 1578.47,
## 7114.56, 2726.04, 2083.09, 8964.54, 11903.93, 18919.66, 5729.18,
## 6155.57, 2906.33, 4492.67, 8712.27, 4020.44, 87058.74, 5736.68,
## 39256.54, 3098.1, 1657.88, 6098.46, 2393.83, 698.27, 539.43,
## 4924.74, 5696.89, 2444.83, 1547.28, 3314.93, 2109.62, 2597.38,
## 2568.79, 2568.79, 4157.23, 2240.12, 2904.57, 17596.38, 22300.21,
## 6939.57, 1736.68, 1314.2, 2429.21, 1374.35, 21026.39, 9310.18,
## 227111.93, 5620.8, 2080.25, 15144.97, 20161.66, 1191.74,
## 3668.3, 3783.8, 6192.41, 158794.92, 19172.73, 8720.92, 207097.89,
## 2100.08, 2423.16, 2848.75, 6338.75, 9212.51, 4446.2, 2761.28,
## 908.08, 26647.84, 3513.95, 4531.74, 2177.64, 4351.49, 57019.94,
## 1316.78, 6684.46, 2991.24, 1426.06, 1315.87, 16281.27, 3537.83,
## 5260.27, 9320.38, 9695.33, 34462.6, 4986.07, 49503.87, 8141.77,
## 610.57, 31735.98, 9847.8, 2524.25, 2934.14, 9278.9, 1516.05,
## 19681.54, 21105.1, 6177, 2630.14, 4733.94, 1442.12, 5230.4,
## 62271.21), c(12.8, 7.9, 4.9, 5.8, 8.2, 8, 13.4, 12.9, 4.6,
## 17.7, 5.4, 20.6, 4.9, 6.4, 5.7, 6.8, 7.4, 6.2, 5.4, 19.9,
## 5.6, 4.7, 6.5, 9.5, 6.4, 48.6, 5.9, 5.3, 15.5, 23.1, 6.4,
## 6.9, 7.9, 5.3, 14.4, 11.1, 9, 10.5, 7.2, 7.4, 9, 6.9, 11.7,
## 6, 16.4, 8.9, 13.4, 6.2, 4.9, 6.2, 5.7, 8.3, 15.5, 4, 20.8,
## 4.8, 6.6, 7.2, 9.1, 7.4, 5.9, 29.1, 8.3, 6.3, 3.7, 10.9,
## 15.3, 8.5, 3.3, 7.3, 7, 6.9, 10.1, 15.2, 20.5, 7.4, 5.2,
## 7.4, 12, 5.3, 7.5, 5.2, 5.2, 11.5, 9.4, 13.2, 20.3, 7.6,
## 27.4, 4.9, 7.7, 7.8, 30.5, 11.2, 5.3, 13.9, 7.8, 5.2, 4.8,
## 7.4, 15.7, 5.7, 7.2, 5.4, 7.5, 5.3, 8.3, 5, 9.1, 8.2, 10,
## 9.8, 7.1, 14.9, 19.3, 6.5, 11.4, 8.2, 8, 5.5, 9.7, 5.9, 14.4,
## 15.7, 12, 8.8, 5.9, 6.6, 6.2, 18.6), c(2, 1.5, 1.6, 1.6,
## 1.3, 2, 1.8, 1.2, 1.6, 2, 1.7, 1.5, 1.6, 1.8, 1.5, 1.7, 1.8,
## 1.7, 2.1, 2.2, 1.5, 1.5, 1.6, 1.8, 1.7, 1.9, 1.7, 1.4, 1.7,
## 1.7, 1.6, 1.6, 1.7, 1.5, 1.6, 1.4, 1.7, 1.8, 1.5, 1.6, 1.4,
## 1.3, 1.6, 1.7, 1.7, 2, 1.6, 1.8, 1.8, 1.6, 1.6, 1.7, 1.8,
## 2.1, 3, 1.6, 1.7, 1.5, 1.7, 1.5, 1.5, 1.7, 1.6, 1.5, 2.1,
## 1.4, 1.4, 1.6, 1.9, 1.5, 1.6, 1.5, 1.9, 1.6, 1.8, 1.6, 1.8,
## 1.9, 1.8, 1.8, 1.4, 1.7, 1.6, 1.8, 1.5, 2.2, 2.1, 1.5, 1.5,
## 1.6, 1.6, 1.8, 1.4, 1.8, 1.8, 1.9, 1.5, 1.7, 1.7, 1.8, 1.5,
## 1.6, 1.9, 1.8, 1.5, 1.7, 1.7, 1.8, 1.6, 1.6, 1.7, 2, 1.4,
## 1.7, 1.8, 1.6, 1.6, 1.6, 1.5, 1.5, 1.5, 1.6, 1.6, 1.4, 1.6,
## 1.5, 1.7, 1.5, 1.6, 2)), control = list(20, 7, 0, 4, 5, 2,
## 0, 30, 0))
## n= 130
##
## CP nsplit rel error
## 1 0.21392330 0 1.0000000
## 2 0.03974681 1 0.7860767
## 3 0.03787457 2 0.7463299
## 4 0.03377736 3 0.7084553
##
## Variable importance
## pib pop icms ipi vab ipva
## 20 16 16 16 15 13
## pop_ocu_per
## 3
##
## Node number 1: 130 observations, complexity param=0.2139233
## mean=1.676154, MSE=0.04920059
## left son=2 (114 obs) right son=3 (16 obs)
## Primary splits:
## pib < 1152899000 to the left, improve=0.2139233, (0 missing)
## ipi < 558.5 to the left, improve=0.2120691, (0 missing)
## icms < 138212.8 to the left, improve=0.2120691, (0 missing)
## vab < 317666500 to the left, improve=0.1385581, (0 missing)
## pop_ocu_per < 17.05 to the left, improve=0.1055147, (0 missing)
## Surrogate splits:
## pop < 75754.5 to the left, agree=0.977, adj=0.812, (0 split)
## icms < 100085.4 to the left, agree=0.977, adj=0.812, (0 split)
## ipi < 405.08 to the left, agree=0.977, adj=0.812, (0 split)
## vab < 457877600 to the left, agree=0.969, adj=0.750, (0 split)
## ipva < 27413.98 to the left, agree=0.954, adj=0.625, (0 split)
##
## Node number 2: 114 observations, complexity param=0.03974681
## mean=1.637719, MSE=0.02848954
## left son=4 (90 obs) right son=5 (24 obs)
## Primary splits:
## pop_ocu_per < 5.45 to the right, improve=0.07827549, (0 missing)
## pop < 57558.5 to the left, improve=0.06007467, (0 missing)
## pib < 355729000 to the left, improve=0.04534830, (0 missing)
## icms < 38139.45 to the left, improve=0.03824473, (0 missing)
## ipi < 154.31 to the left, improve=0.03824473, (0 missing)
##
## Node number 3: 16 observations
## mean=1.95, MSE=0.11125
##
## Node number 4: 90 observations, complexity param=0.03787457
## mean=1.613333, MSE=0.02448889
## left son=8 (68 obs) right son=9 (22 obs)
## Primary splits:
## pib < 447616800 to the left, improve=0.10991320, (0 missing)
## vab < 108727000 to the left, improve=0.10106620, (0 missing)
## pop < 61064.5 to the left, improve=0.09177478, (0 missing)
## icms < 39233.84 to the left, improve=0.07276027, (0 missing)
## ipi < 158.695 to the left, improve=0.07276027, (0 missing)
## Surrogate splits:
## pop < 41344.5 to the left, agree=0.956, adj=0.818, (0 split)
## vab < 108727000 to the left, agree=0.956, adj=0.818, (0 split)
## icms < 37221.12 to the left, agree=0.944, adj=0.773, (0 split)
## ipi < 152.04 to the left, agree=0.944, adj=0.773, (0 split)
## ipva < 9865.655 to the left, agree=0.922, adj=0.682, (0 split)
##
## Node number 5: 24 observations
## mean=1.729167, MSE=0.03289931
##
## Node number 8: 68 observations
## mean=1.583824, MSE=0.01929715
##
## Node number 9: 22 observations
## mean=1.704545, MSE=0.02952479
## note: only 6 unique complexity parameters in default grid. Truncating the grid to 6 .
##
## Aggregating results
## Selecting tuning parameters
## Fitting mtry = 3 on full training set
## Aggregating results
## Selecting tuning parameters
## Fitting mstop = 50, prune = no on full training set
## Boosted Generalized Linear Model
##
## 130 samples
## 7 predictor
##
## No pre-processing
## Resampling: Cross-Validated (10 fold)
## Summary of sample sizes: 116, 117, 117, 118, 117, 118, ...
## Resampling results across tuning parameters:
##
## mstop RMSE Rsquared MAE
## 50 0.2042264 0.1831534 0.1529216
## 100 0.2095338 0.2060137 0.1536587
## 150 0.2150620 0.2170094 0.1546601
## 200 0.2204597 0.2215629 0.1560612
## 250 0.2252353 0.2250923 0.1571951
## 300 0.2297131 0.2284649 0.1583479
## 350 0.2337211 0.2312378 0.1594117
## 400 0.2372954 0.2338719 0.1603547
## 450 0.2404157 0.2357173 0.1611741
## 500 0.2432714 0.2374265 0.1619084
## 550 0.2457805 0.2396897 0.1625161
## 600 0.2480406 0.2417697 0.1630674
## 650 0.2500663 0.2433059 0.1635627
## 700 0.2505879 0.2454942 0.1635722
## 750 0.2507893 0.2467122 0.1635075
## 800 0.2510175 0.2487379 0.1634388
## 850 0.2512230 0.2505170 0.1633634
## 900 0.2513818 0.2522773 0.1632732
## 950 0.2516119 0.2536995 0.1632143
## 1000 0.2517987 0.2549045 0.1631612
##
## Tuning parameter 'prune' was held constant at a value of no
## RMSE was used to select the optimal model using the smallest value.
## The final values used for the model were mstop = 50 and prune = no.
##
## Generalized Linear Models Fitted via Gradient Boosting
##
## Call:
## (function (formula, data = list(), weights = NULL, offset = NULL, family = Gaussian(), na.action = na.pass, contrasts.arg = NULL, center = TRUE, control = boost_control(), oobweights = NULL, ...) { if (length(formula[[3]]) == 1) { if (as.name(formula[[3]]) == ".") { formula <- as.formula(paste(deparse(formula[[2]]), "~", paste(names(data)[names(data) != all.vars(formula[[2]])], collapse = "+"), collapse = "")) } } cl <- match.call() mf <- match.call(expand.dots = FALSE) m <- match(c("formula", "data", "weights", "na.action"), names(mf), 0L) mf <- mf[c(1L, m)] mf$drop.unused.levels <- TRUE mf$data <- data mf[[1L]] <- quote(stats::model.frame) mf <- eval(mf, parent.frame()) if (!control$center) { center <- FALSE warning("boost_control(center = FALSE) is deprecated, use glmboost(..., center = FALSE)") } X <- model.matrix(attr(mf, "terms"), data = mf, contrasts.arg = contrasts.arg) assign <- attr(X, "assign") cm <- numeric(ncol(X)) if (center) { if (!attr(attr(mf, "terms"), "intercept") == 1) warning("model with centered covariates does not contain intercept") cm <- colMeans(X, na.rm = TRUE) cm[assign == 0] <- 0 X <- scale(X, center = cm, scale = FALSE) } newX <- function(newdata) { mf <- model.frame(delete.response(attr(mf, "terms")), data = newdata, na.action = na.action) X <- model.matrix(delete.response(attr(mf, "terms")), data = mf, contrasts.arg = contrasts.arg) scale(X, center = cm, scale = FALSE) } bl <- list(bolscw(X)) response <- model.response(mf) weights <- model.weights(mf) ret <- mboost_fit(bl, response = response, weights = weights, offset = offset, family = family, control = control, oobweights = oobweights, ...) ret$newX <- newX ret$assign <- assign ret$center <- cm ret$call <- cl ret$hatvalues <- function() { H <- vector(mode = "list", length = ncol(X)) MPinv <- ret$basemodel[[1]]$MPinv() for (j in unique(ret$xselect())) H[[j]] <- (X[, j] %*% MPinv[j, , drop = FALSE]) * control$nu H } ret$rownames <- rownames(mf) ret$model.frame <- function(which = NULL) { if (!is.null(which)) warning("Argument ", sQuote("which"), " is ignored") mf } update <- ret$update ret$update <- function(weights = NULL, oobweights = NULL, risk = "oobag", trace = NULL) { res <- update(weights = weights, oobweights = oobweights, risk = risk, trace = trace) res$newX <- newX res$assign <- assign res$center <- cm res$call <- cl res$hatvalues <- function() { H <- vector(mode = "list", length = ncol(X)) MPinv <- res$basemodel[[1]]$MPinv() for (j in unique(res$xselect())) H[[j]] <- (X[, j] %*% MPinv[j, , drop = FALSE]) * control$nu H } res$rownames <- rownames(mf) res$model.frame <- function(which = NULL) { if (!is.null(which)) warning("Argument ", sQuote("which"), " is ignored") mf } class(res) <- c("glmboost", "mboost") res } class(ret) <- c("glmboost", "mboost") return(ret)})(formula = .outcome ~ ., data = "structure(list(pop = c(100346, 25065, 37082, 22984, 22870, 11226, ", family = new("boost_family_glm", fW = function (f) return(rep(1, length = length(f))), ngradient = function (y, f, w = 1) y - f, risk = function (y, f, w = 1) sum(w * loss(y, f), na.rm = TRUE), offset = function (x, w, ...) UseMethod("weighted.mean"), check_y = function (y) { if (!is.numeric(y) || !is.null(dim(y))) stop("response is not a numeric vector but ", sQuote("family = Gaussian()")) y }, weights = function (w) { switch(weights, any = TRUE, none = isTRUE(all.equal(unique(w), 1)), zeroone = isTRUE(all.equal(unique(w + abs(w - 1)), 1)), case = isTRUE(all.equal(unique(w - floor(w)), 0))) }, nuisance = function () return(NA), response = function (f) f, rclass = function (f) NA, name = "Squared Error (Regression)", charloss = "(y - f)^2 \n"), control = structure(list(mstop = 50, nu = 0.1, risk = "inbag", stopintern = FALSE, center = TRUE, trace = FALSE), class = "boost_control"), x = "xData", y = "yData")
##
##
## Squared Error (Regression)
##
## Loss function: (y - f)^2
##
##
## Number of boosting iterations: mstop = 50
## Step size: 0.1
## Offset: 1.676154
##
## Coefficients:
## (Intercept) pib ipi ipva pop_ocu_per
## -3.739448e-02 4.124496e-11 5.400149e-05 -4.412225e-07 3.734836e-04
## attr(,"offset")
## [1] 1.676154
##
## Selection frequencies:
## pib ipva ipi pop_ocu_per
## 0.48 0.30 0.18 0.04
##
## Call:
## resamples.default(x = list(LM = municipios_LM, RPART = municipios_RPART, RF
## = municipios_RF, GLMBOOST = municipios_GLMB))
##
## Models: LM, RPART, RF, GLMBOOST
## Number of resamples: 10
## Performance metrics: MAE, RMSE, Rsquared
## Time estimates for: everything, final model fit
##
## Call:
## summary.resamples(object = melhor_modelo)
##
## Models: LM, RPART, RF, GLMBOOST
## Number of resamples: 10
##
## MAE
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## LM 0.11250426 0.1365069 0.1452234 0.1500140 0.1579638 0.2074719 0
## RPART 0.10031459 0.1271278 0.1359506 0.1528806 0.1666096 0.2361921 0
## RF 0.09966572 0.1374797 0.1488906 0.1504210 0.1745556 0.1945268 0
## GLMBOOST 0.13586466 0.1392127 0.1483762 0.1529216 0.1580298 0.2040739 0
##
## RMSE
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## LM 0.1403318 0.1668707 0.1823795 0.1977971 0.1945958 0.3738177 0
## RPART 0.1323618 0.1592376 0.1846160 0.2019010 0.2068152 0.3577999 0
## RF 0.1309655 0.1629643 0.1899645 0.2008156 0.2271987 0.3318397 0
## GLMBOOST 0.1622121 0.1732080 0.1880893 0.2042264 0.2056509 0.3643783 0
##
## Rsquared
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## LM 0.0009112821 0.02468258 0.09255976 0.1828879 0.3366001 0.5605766 0
## RPART 0.0164734594 0.05615441 0.22041347 0.1906448 0.2755084 0.4544527 0
## RF 0.0028397725 0.02329336 0.09198198 0.1797962 0.3578080 0.4839327 0
## GLMBOOST 0.0275083393 0.04190270 0.17261687 0.1831534 0.2404946 0.6005926 0